﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace TDUpdate
{
    public class Level : UpdateComponent
    {
        public TileEnum[,] Tiles
        {
            get { return tiles; }
            private set { tiles = value; OnPropertyChanged("Tiles"); }
        }
        public Point SelectedTile
        {
            get { return selectedTile; }
            private set { selectedTile = value; OnPropertyChanged("SelectedTile"); }
        }

        TileEnum[,] tiles; // Bei Änderungen an dem Array immer OnPropertyChanged() aufrufen damit die Änderungen gezeichnet werden.
        Point selectedTile;

        public Level()
        {
            this.loadSampleData();
            UpdateManager.Mouse.MouseClicked +=new EventHandler<MouseStateChangedEventArgs>(MouseClicked);
        }

        void loadSampleData()
        {
            Tiles = LevelLoader.loadTextFile("Level1");
        }

        public override void Update()
        {

        }

        void MouseClicked(object sender, MouseStateChangedEventArgs e)
        {
            if (e.innerObject != null && e.handled == false)
                SelectedTile = (Point)e.innerObject;
            e.handled = true;
        }
    }
}
